import time

import requests
import app


class CreateGroupBuy:
    def __init__(self):
        # 创建团购
        self.post_create_group_buy_url = "https"+app.BASE_URL + "/vega-server/cxfx/groupbuy/"+"save"

    # 创建团购
    def post_create_group_buy(self,name,days,hours,mins,goodsNo,goodsname,weight,goodsPrice):
        """
        :param name: 团购标题
        :param days: 团购结束时间几天后
        :return:
        """
        myJson = {"cxfxGroupBuy":{"groupNo":"","name":name,"explain":"一二三四五六七八九十","beginTime":app.onedaytime(0,0,0),"endTime":app.onedaytime(days,hours,mins),"community":"11","area":"湖北省武汉市武昌区汉街42号","pickUpAddress":"提货地址","copies":"1","log":114.31599,"lat":30.55386},"cxfxGroupBuyDetailList":[{"storeNum":"3","detail":"描述","goodsNo":goodsNo,"goodsname":goodsname,"weight":weight,"goodsPrice":goodsPrice}],"photoList":[{"photoUrl":"https://img.weitaikeji.com/20200414fc05beeccde54f488e219cc35b01e044.png"}]}
        myHeads = {"Content-Type": "application/json","token":app.TOKEN}
        return requests.post(url=self.post_create_group_buy_url,json=myJson,headers=myHeads,verify=False)

    # 获取团购列表

if __name__ == '__main__':
    a = CreateGroupBuy().post_create_group_buy("ceshi",3).json
    print(a)